package com.dv.web.controller.systemevent;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dv.common.annotation.Log;
import com.dv.common.core.controller.BaseController;
import com.dv.common.core.domain.AjaxResult;
import com.dv.common.enums.BusinessType;
import com.dv.driverless.domain.InfoException;
import com.dv.driverless.service.IInfoExceptionService;
import com.dv.common.utils.poi.ExcelUtil;
import com.dv.common.core.page.TableDataInfo;

/**
 * 异常信息Controller
 *
 * @author ruoyi
 * @date 2023-04-06
 */
@RestController
@RequestMapping("/systemevent/exception")
public class InfoExceptionController extends BaseController
{
    @Autowired
    private IInfoExceptionService infoExceptionService;

    /**
     * 查询异常信息列表
     */
    @PreAuthorize("@ss.hasPermi('systemevent:exception:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoException infoException)
    {
        startPage();
        List<InfoException> list = infoExceptionService.selectInfoExceptionList(infoException);
        return getDataTable(list);
    }

    /**
     * 导出异常信息列表
     */
    @PreAuthorize("@ss.hasPermi('systemevent:exception:export')")
    @Log(title = "异常信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoException infoException)
    {
        List<InfoException> list = infoExceptionService.selectInfoExceptionList(infoException);
        ExcelUtil<InfoException> util = new ExcelUtil<InfoException>(InfoException.class);
        util.exportExcel(response, list, "异常信息数据");
    }

    /**
     * 获取异常信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('systemevent:exception:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(infoExceptionService.selectInfoExceptionById(id));
    }

    /**
     * 新增异常信息
     */
    @PreAuthorize("@ss.hasPermi('systemevent:exception:add')")
    @Log(title = "异常信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoException infoException)
    {
        return toAjax(infoExceptionService.insertInfoException(infoException));
    }

    /**
     * 修改异常信息
     */
    @PreAuthorize("@ss.hasPermi('systemevent:exception:edit')")
    @Log(title = "异常信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoException infoException)
    {
        return toAjax(infoExceptionService.updateInfoException(infoException));
    }

    /**
     * 删除异常信息
     */
    @PreAuthorize("@ss.hasPermi('systemevent:exception:remove')")
    @Log(title = "异常信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoExceptionService.deleteInfoExceptionByIds(ids));
    }
}
